home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / board / Chaos53src.lha / chaos / src / main.c < prev    next >
C/C++ Source or Header  |  1994-11-19  |  4KB  |  177 lines

  1. /*  Chaos:            The Chess HAppening Organisation System    V5.3
  2.     Copyright (C)   1993    Jochen Wiedmann
  3.  
  4.     This program is free software; you can redistribute it and/or modify
  5.     it under the terms of the GNU General Public License as published by
  6.     the Free Software Foundation; either version 2 of the License, or
  7.     (at your option) any later version.
  8.  
  9.     This program is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.     GNU General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU General Public License
  15.     along with this program; if not, write to the Free Software
  16.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18.  
  19.     $RCSfile: main.c,v $
  20.     $Revision: 3.3 $
  21.     $Date: 1994/11/19 19:32:01 $
  22.  
  23.     This file contains main() and some other global stuff.
  24.  
  25.     Computer:    Amiga 1200            Compiler:    Dice 2.07.54 (3.0)
  26.  
  27.     Author:    Jochen Wiedmann
  28.         Am Eisteich 9
  29.       72555 Metzingen
  30.         Tel. 07123 / 14881
  31.         Internet: wiedmann@mailserv.zdv.uni-tuebingen.de
  32. */
  33.  
  34.  
  35. char *AVERSION = "Chaos V5.3";
  36. char *PVERSION = "Chaos V5.3     (C) 1993        by  Jochen Wiedmann";
  37. char *VERVERSION = "$VER: Chaos 5.3 (23.03.94)";
  38.  
  39.  
  40. #ifndef CHAOS_H
  41. #include "chaos.h"
  42. #endif
  43.  
  44.  
  45. /*
  46.     Global variables
  47. */
  48. struct List PlayerList;
  49. int IsSaved                = TRUE;
  50. int OutputDevice            = FALSE;
  51. char TrnFileName [TRNFILENAME_LEN+1]    = "";
  52. int AllowErrorMessage            = TRUE;
  53. int DefaultWinnerPoints         = 2;
  54. int DefaultDrawPoints            = 1;
  55.  
  56. /*
  57.     The following global variables get saved into the tournament file.
  58. */
  59. int NumRounds                = 0;
  60. struct Player *RankingFirst        = NULL;
  61. int NumPlayers                = 0;
  62. int NumGamesMissing;
  63. char TrnName [TRNNAME_LEN+1]        = "";
  64. int WinnerPoints;
  65. int DrawPoints;
  66. int TrnMode                = TNMODEF_SWISS_PAIRING;
  67.  
  68.  
  69.  
  70. /*
  71.     The Cleanup() function gets called when the program terminates.
  72. */
  73. void Cleanup(void)
  74.  
  75.   {
  76.     TerminateMainWnd();
  77.     PutMemAll();
  78.     CloseLibs();
  79.   }
  80.  
  81.  
  82.  
  83. /*
  84.     Die übliche main()-Funktion
  85. */
  86. void main(int argc, char *argv[])
  87.  
  88. {
  89.   if (atexit(Cleanup))
  90.   { exit(20);
  91.   }
  92.   /*  Initialize the libraries            */
  93.   OpenLibs();
  94.   /*  Initialize the random number generator    */
  95.   InitRandom();
  96.   /*  Initialize the tournament data        */
  97.   DeleteTournament(NULL);
  98.   /*  Process the arguments            */
  99.   DoStartup(argc, argv);
  100.  
  101.   InitMainWnd();
  102.   ProcessMainWnd();
  103. }
  104.  
  105.  
  106.  
  107. /*
  108.     wbmain() gets called from DICE startup code when running from the
  109.     Workbench. We do nothing special except calling main() to be Aztec
  110.     compatible.
  111. */
  112. #ifdef _DCC
  113. void wbmain(void *wbmsg)
  114.  
  115. { main(0, (char **) wbmsg);
  116. }
  117. #endif    /*  _DCC    */
  118.  
  119.  
  120.  
  121. #ifdef DEBUG
  122. #undef strlen
  123. size_t dbg_strlen(const char *ptr)
  124. { if (ptr == NULL)
  125.   { printf("strlen: NULL pointer!\n");
  126.   }
  127.   return(strlen(ptr));
  128. }
  129.  
  130. #undef strcpy
  131. char *dbg_strcpy(char *dest, const char *src)
  132. { if (src == NULL  ||  dest == NULL)
  133.   { printf("strcpy: NULL pointer!\n");
  134.   }
  135.   return(strcpy (dest, src));
  136. }
  137.  
  138. #undef printf
  139. int dbg_printf(const char *fmt, ...)
  140. { char **args = &fmt;
  141.  
  142.   if (fmt == NULL)
  143.   { printf("printf: NULL pointer!\n");
  144.   }
  145.   return(printf(fmt, args[1], args[2], args[3], args[4], args[5], args [6],
  146.      args[7], args[8], args[9], args[10], args[11], args[12], args[13],
  147.      args[14], args[15], args[16], args[17], args[18], args[19],
  148.      args[20]));
  149. }
  150.  
  151. #undef sprintf
  152. int dbg_sprintf(char *dest, const char *fmt, ...)
  153. { char **args = &fmt;
  154.  
  155.   if (dest == NULL  ||  fmt == NULL)
  156.   { printf("sprintf: NULL pointer!\n");
  157.   }
  158.   return(sprintf(dest, fmt, args[1], args[2], args[3], args[4], args[5],
  159.      args [6], args[7], args[8], args[9], args[10], args[11], args[12],
  160.      args[13], args[14], args[15], args[16], args[17], args[18],
  161.      args[19], args[20]));
  162. }
  163.  
  164. #undef fprintf
  165. int dbg_fprintf(FILE *fh, const char *fmt, ...)
  166. { char **args = &fmt;
  167.  
  168.   if (fh == NULL  ||  fmt == NULL)
  169.   { printf("fprintf: NULL pointer!\n");
  170.   }
  171.   return(fprintf(fh, fmt, args[1], args[2], args[3], args[4], args[5],
  172.      args [6], args[7], args[8], args[9], args[10], args[11], args[12],
  173.      args[13], args[14], args[15], args[16], args[17], args[18],
  174.      args[19], args[20]));
  175. }
  176. #endif
  177.